/*
 * Copyright (C) 2012 Nicolas BARBOTIN
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef GCDATAREADER_H
#define GCDATAREADER_H

#include <QtCore>
#include <QtXml/QtXml>
#include <quazip/quazip.h>
#include <quazip/quazipfile.h>
#include <quazip/quazipnewinfo.h>
#include <iostream>
#include "GCProject.h"
#include "GCStructs.h"

class GCProject;

class GCDataReader : public QObject
{
    Q_OBJECT
private:
    QMap<int, GCCat> cats;
    QMap<int, GCCat> acats;
    QList<GCActionType> actions;
    QList<GCEventType> events;

    GCEventType ReadEvent(QString fle);
    GCActionType ReadAction(QString fle);
    QString getDate();
    static EnumParamType scanType(QString type);

public:
    GCDataReader(QObject *parent = 0);

    int countEvents() { return events.count(); }
    int countActions() { return actions.count(); }

    GCEventType getEvent(int i) { return events[i]; }
    GCActionType getAction(int i) { return actions[i]; }

    GCCat getCategory(int i) { return cats.value(i); }
    int countEventCats() { return cats.count(); }
    int getEventCatIndex(int i) { return cats.keys()[i]; }

    GCCat getACategory(int i) { return acats.value(i); }
    int countActionCats() { return acats.count(); }
    int getActionCatIndex(int i) { return acats.keys()[i]; }

    void saveProject(GCProject *p);
    bool loadProject(GCProject *p, QString s = QString());

};

#endif // GCDATAREADER_H
